#include "cell.h"
#include "graphics.h"
#include <SDL.h>

Cell::Cell()
{

}

Cell::Cell(Graphics &G, int Type, SDL_Point Position) : Sprite(G, "Content/Cells/Sky.png", 0, 0, 16, 16, 0, 0)
{
	//G.LoadImage("Content/Cells/Sky.png");
	X = Position.x * 16;
	Y = Position.y * 16;
	CR = SDL_Rect();
	CR.w = 16;
	CR.h = 16;
	this->Type = Type;
	if (Type != 0)
	{
		CR.x = X;
		CR.y = Y;
	}
	else
	{
		CR.x = -16;
		CR.y = -16;
	}
	if (Type == 1)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/Dirt.png"));
	}
	if (Type == 2)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/DirtCorner.png"));
	}
	if (Type == 3)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/DirtCorner.png"));
	}
	if (Type == 4)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/Grass.png"));
	}
	if (Type == 5)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/GrassCorner.png"));
	}
	if (Type == 6)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/GrassCorner.png"));
	}
	if (Type == 7)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/FloatLeft.png"));
	}
	if (Type == 8)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/FloatCenter.png"));
	}
	if (Type == 9)
	{
		Tex = SDL_CreateTextureFromSurface(G.Ren, G.LoadImage("Content/Cells/FloatRight.png"));
	}
}

void Cell::Draw(Graphics &G)
{
	if (Type == 1 || Type == 3 || Type == 4 || Type == 5 || Type == 7 || Type == 8 || Type == 9)
		Sprite::Draw(G, SDL_RendererFlip::SDL_FLIP_NONE);
	if (Type == 2 || Type == 6)
		Sprite::Draw(G, SDL_RendererFlip::SDL_FLIP_HORIZONTAL);
}